namespace CloudNinja.Metering.Data
{
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Threading.Tasks;

    using CloudNinja.Metering.Data.Models;

    public class TraceMeteringRepository : IMeteringRepository
    {
        public void Write(string meterTypeId, string tenantId, double value, DateTimeOffset timeStamp, int count)
        {
            Trace.WriteLine(
                string.Format(
                    "Meter type: {0}, tenantId: {1}, value: {2}, when: {3}, count: {4}",
                    meterTypeId,
                    tenantId,
                    value,
                    timeStamp,
                    count));
        }

        public void Write(MeterData dataPoint)
        {
            this.Write(new[] { dataPoint });
        }

        public void Write(IEnumerable<MeterData> dataPoints)
        {
            foreach (var meterDataPoint in dataPoints)
            {
                this.Write(meterDataPoint.MeterTypeId, meterDataPoint.TenantId, meterDataPoint.Value, meterDataPoint.TimePeriod, meterDataPoint.Count);
            }
        }
    }
}